<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        html,
        body,
        #app {
            height: 100%;
        }

        .main {
            height: 100%;
            background-color: #eee;
        }

        .container {
            width: 300px;
            background-color: #fff;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- @click="isShow=true"点击时显示main -->
        <button @click="isShow=true">show</button>
        <!-- @click="isShow=false"点击时main区域时，main隐藏 -->
        <div class="main" v-show="isShow" @click="isShow=false">
            <!-- 在container上需要使用@click.stop来阻止冒泡，否则当用鼠标在文本框中点击获取焦点时，会冒泡触发main中的点击操作 -->
            <div class="container" @click.stop>
                <p>用户名：<input type="text"></p>
                <p>密&emsp;码：<input type="password"></p>
                <hr>
                <p><button>登录</button></p>
            </div>
        </div>
    </div>
    <script src='./js/vue.js'></script>
    <script>
        new Vue({
            el: "#app",
            data: {
                isShow: false
            }
        })
    </script>
</body>

</html>